package cn.biplam.front.template.buttons;

import cn.biplam.common.paramters.SysCaption;
import cn.biplam.common.wrapper.ErrorMessage;
import cn.biplam.common.wrapper.UserInfo;
import cn.biplam.front.component.data.common.ButtonComp;
import cn.biplam.front.html.base.HtmlWindow;
import cn.biplam.front.html.base.Const.Window_Event;
import cn.biplam.front.htmlscript.script.AjxScript;
import cn.biplam.front.template.Template;

/**
 * 保存按钮模板<BR>
 */
public class SaveButton implements Template{
	
	private UserInfo mUser;
	private String cID;
	private String aID;

	/**
	 * 需要rid的刷新
	 * @param mUser		用户信息类
	 * @param cID		提交的容器ID
	 * @param aID		提交的actionID
	 */
	public SaveButton(UserInfo mUser,String cID,String aID){
		this.mUser=mUser;
		this.cID=cID;
		this.aID=aID;
	}

	/**
	 * 返回按钮页面组件
	 * @return	HtmlWindow
	 * @throws ErrorMessage
	 */
	public HtmlWindow get() throws ErrorMessage {
		HtmlWindow refreshBt=ButtonComp.get(mUser, SysCaption.Save);
		refreshBt.bind(Window_Event.OnClick, this.getScript());
		return refreshBt;
	}
	
	/**
	 * 返回按钮点击时执行的脚本
	 * @return String
	 */
	public String getScript(){
		return AjxScript.getSpNoRefresh(cID, aID);
	}
}
